package com.cn.laoluobase.jo;


import javax.annotation.Resource;

public class BusinessException extends RuntimeException{


    private Integer code;
    private String msg;

    public BusinessException(Integer code,String msg){
        this.code=code;
        this.msg   =msg;
    }

    public BusinessException(String MyHttpEnumName){
        MyHttpEnum httpEnum=MyHttpEnum.byName(MyHttpEnumName);
        this.code=httpEnum.getCode();
        this.msg=httpEnum.getMsg();
    }



    // 业务异常类，可能有很多code,我们定义一个按名称去查找的方法。
    public static BusinessException byName(String name){
        MyHttpEnum httpEnum=MyHttpEnum.byName(name);
        return new BusinessException(httpEnum.getCode(), httpEnum.getMsg());
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
